= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
  = form_errors(@application_setting)

  %fieldset
    %legend 可见性与访问控制
    .form-group
      = f.label :default_branch_protection, '默认保护分支', class: 'control-label col-sm-2'
      .col-sm-10
        = f.select :default_branch_protection, options_for_select(Gitlab::Access.protection_options, @application_setting.default_branch_protection), {}, class: 'form-control'
    .form-group.project-visibility-level-holder
      = f.label :default_project_visibility, '默认项目可见度', class: 'control-label col-sm-2'
      .col-sm-10
        = render('shared/visibility_radios', model_method: :default_project_visibility, form: f, selected_level: @application_setting.default_project_visibility, form_model: Project.new)
    .form-group.project-visibility-level-holder
      = f.label :default_snippet_visibility, '默认代码片段可见度', class: 'control-label col-sm-2'
      .col-sm-10
        = render('shared/visibility_radios', model_method: :default_snippet_visibility, form: f, selected_level: @application_setting.default_snippet_visibility, form_model: ProjectSnippet.new)
    .form-group.group-visibility-level-holder
      = f.label :default_group_visibility, '默认群组可见度', class: 'control-label col-sm-2'
      .col-sm-10
        = render('shared/visibility_radios', model_method: :default_group_visibility, form: f, selected_level: @application_setting.default_group_visibility, form_model: Group.new)
    .form-group
      = f.label :restricted_visibility_levels, '限制的可见等级', class: 'control-label col-sm-2'
      .col-sm-10
        - data_attrs = { toggle: 'buttons' }
        .btn-group{ data: data_attrs }
          - restricted_level_checkboxes('restricted-visibility-help').each do |level|
            = level
        %span.help-block#restricted-visibility-help
          选择的等级将无法用于非管理用户的项目和代码片段。
          如果公开等级被限制，用户个人资料只对已登录用户可见。
    .form-group
      = f.label :import_sources, '导入来源', class: 'control-label col-sm-2'
      .col-sm-10
        - data_attrs = { toggle: 'buttons' }
        .btn-group{ data: data_attrs }
          - import_sources_checkboxes('import-sources-help').each do |source|
            = source
        %span.help-block#import-sources-help
          项目创建时可用的代码导入来源。GitHub
          = link_to "(?)", help_page_path("integration", "github")
          、Bitbucket
          = link_to "(?)", help_page_path("integration", "bitbucket")
          和 GitLab.com
          = link_to "(?)", help_page_path("integration", "gitlab")
          必须先配置好 OmniAuth。
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :version_check_enabled do
            = f.check_box :version_check_enabled
            开启版本检查
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :email_author_in_body do
            = f.check_box :email_author_in_body
            在通知邮件正文包含作者名称
          .help-block
            有些邮件服务器不支持重写邮件发送人名称功能。
            开启此选项将在邮件正文中提供问题、合并请求和评论作者的名称，
            否则只试图重写邮件发送人为作者。
    .form-group
      = f.label :admin_notification_email, '管理员通知邮箱', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :admin_notification_email, class: 'form-control'
        .help-block
          滥用举报会使用此邮箱发送邮件。滥用举报总是在管理区域可用。

  %fieldset
    %legend 账户与限制设置
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :gravatar_enabled do
            = f.check_box :gravatar_enabled
            开启 Gravatar 头像
    .form-group
      = f.label :default_projects_limit, '默认项目限制', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :default_projects_limit, class: 'form-control'
    .form-group
      = f.label :max_attachment_size, '最大附件大小 (MB)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :max_attachment_size, class: 'form-control'
    .form-group
      = f.label :session_expire_delay, '会话保留时间 (分钟)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :session_expire_delay, class: 'form-control'
        %span.help-block#session_expire_delay_help_block 要应用此变更需要重启 GitLab
    .form-group
      = f.label :user_oauth_applications, '用户 OAuth 应用', class: 'control-label col-sm-2'
      .col-sm-10
        .checkbox
          = f.label :user_oauth_applications do
            = f.check_box :user_oauth_applications
            允许用户注册使用 GitLab 为 OAuth 提供者的应用

  %fieldset
    %legend 登录限制
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :signup_enabled do
            = f.check_box :signup_enabled
            开启注册
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :send_user_confirmation_email do
            = f.check_box :send_user_confirmation_email
            注册时发送确认邮件
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :signin_enabled do
            = f.check_box :signin_enabled
            开启登录
    - if omniauth_enabled? && button_based_providers.any?
      .form-group
        = f.label :enabled_oauth_sign_in_sources, '开启 OAuth 登录来源', class: 'control-label col-sm-2'
        .col-sm-10
          .btn-group{ data: { toggle: 'buttons' } }
            - oauth_providers_checkboxes.each do |source|
              = source
    .form-group
      = f.label :two_factor_authentication, '两步验证', class: 'control-label col-sm-2'
      .col-sm-10
        .checkbox
          = f.label :require_two_factor_authentication do
            = f.check_box :require_two_factor_authentication
            强制全部用户设置两步验证
    .form-group
      = f.label :two_factor_authentication, '两步验证宽限期 (小时)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :two_factor_grace_period, min: 0, class: 'form-control', placeholder: '0'
        .help-block 允许用户跳过强制两步验证配置的时间范围（小时）
    .form-group
      = f.label :restricted_signup_domains, '注册限制域名', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_area :restricted_signup_domains_raw, placeholder: 'domain.com', class: 'form-control'
        .help-block 用户使用的邮箱地址后缀必须匹配这些域名才能注册。泛域名可用。使用英文逗号分隔多个域名。比如：domain.com, *.domain.com
    .form-group
      = f.label :home_page_url, '主页链接', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :home_page_url, class: 'form-control', placeholder: 'http://company.example.com', :'aria-describedby' => 'home_help_block'
        %span.help-block#home_help_block 未登录用户将会重定向到此页面
    .form-group
      = f.label :after_sign_out_path, '退出后路径', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :after_sign_out_path, class: 'form-control', placeholder: 'http://company.example.com', :'aria-describedby' => 'after_sign_out_path_help_block'
        %span.help-block#after_sign_out_path_help_block 用户退出后将会重定向到此页面
    .form-group
      = f.label :sign_in_text, '登录文字', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_area :sign_in_text, class: 'form-control', rows: 4
        .help-block Markdown 可用
    .form-group
      = f.label :help_page_text, '帮助页面文字', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_area :help_page_text, class: 'form-control', rows: 4
        .help-block Markdown 可用

  %fieldset
    %legend 持续集成
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :shared_runners_enabled do
            = f.check_box :shared_runners_enabled
            为新项目默认开启共享 runner
    .form-group
      = f.label :shared_runners_text, '共享 runner 文本', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_area :shared_runners_text, class: 'form-control', rows: 4
        .help-block Markdown 可用
    .form-group
      = f.label :max_artifacts_size, '最大附件大小 (MB)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :max_artifacts_size, class: 'form-control'

  - if Gitlab.config.registry.enabled
    %fieldset
      %legend Container Registry
      .form-group
        = f.label :container_registry_token_expire_delay, 'Authorization token duration (minutes)', class: 'control-label col-sm-2'
        .col-sm-10
          = f.number_field :container_registry_token_expire_delay, class: 'form-control'

  %fieldset
    %legend 度量
    %p
      这些设置需要重启才能生效。
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :metrics_enabled do
            = f.check_box :metrics_enabled
            开启 InfluxDB 度量
    .form-group
      = f.label :metrics_host, 'InfluxDB 主机', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :metrics_host, class: 'form-control', placeholder: 'influxdb.example.com'
    .form-group
      = f.label :metrics_port, 'InfluxDB 端口', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :metrics_port, class: 'form-control', placeholder: '8089'
        .help-block
          用于连接到 InfluxDB 的 UDP 端口。
          InfluxDB 需要您的服务器配置数据库用于存储发送到此端口的消息，
          如果没有配置，度量数据将不会保存。
    .form-group
      = f.label :metrics_pool_size, '连接池大小', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :metrics_pool_size, class: 'form-control'
        .help-block
          可用的 InfluxDB 连接数。
          连接是延迟加载的，即只有需要的时候才会打开。
          使用多线程应用服务器的用户应确保有足够的连接可用
          （可用数至少是应用服务器线程的数量）。
    .form-group
      = f.label :metrics_timeout, '连接超时', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :metrics_timeout, class: 'form-control'
        .help-block
          InfluxDB 连接超时时间，单位秒。
    .form-group
      = f.label :metrics_method_call_threshold, '方法调用阈值 (毫秒)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :metrics_method_call_threshold, class: 'form-control'
        .help-block
          只有超过此给定的毫秒阀值后完成的方法调用才会被跟踪。
    .form-group
      = f.label :metrics_sample_interval, '采样间隔 (秒)', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :metrics_sample_interval, class: 'form-control'
        .help-block
          以秒为单位的采样间隔。
          采样数据包括内存使用、保留的 Ruby 对象、文件描述符等。
    .form-group
      = f.label :metrics_packet_size, '度量包大小', class: 'control-label col-sm-2'
      .col-sm-10
        = f.number_field :metrics_packet_size, class: 'form-control'
        .help-block
          The amount of points to store in a single UDP packet. More points
          results in fewer but larger UDP packets being sent.

  %fieldset
    %legend Spam 与防机器人保护
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :recaptcha_enabled do
            = f.check_box :recaptcha_enabled
            开启 reCAPTCHA
          %span.help-block#recaptcha_help_block Helps prevent bots from creating accounts

    .form-group
      = f.label :recaptcha_site_key, 'reCAPTCHA Site Key', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :recaptcha_site_key, class: 'form-control'
        .help-block
          在后面的网址生成网站密钥 (Site Key) 和私钥 (Private Key)：
          %a{ href: 'http://www.google.com/recaptcha', target: 'blank'} http://www.google.com/recaptcha

    .form-group
      = f.label :recaptcha_private_key, 'reCAPTCHA Private Key', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :recaptcha_private_key, class: 'form-control'

    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :akismet_enabled do
            = f.check_box :akismet_enabled
            开启 Akismet
          %span.help-block#akismet_help_block 用户阻止机器人创建问题

    .form-group
      = f.label :akismet_api_key, 'Akismet API Key', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :akismet_api_key, class: 'form-control'
        .help-block
          在后面的网址生成 API 密钥（API Key）：
          %a{ href: 'http://www.akismet.com', target: 'blank'} http://www.akismet.com

  %fieldset
    %legend 错误报告和日志
    %p
      这些设置需要重启才能生效。
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :sentry_enabled do
            = f.check_box :sentry_enabled
            开启 Sentry
          .help-block
            Sentry 是一个错误报告和日志记录工具。GitLab 当前并未自带此工具，需要在后面的网址下载并安装：
            %a{ href: 'https://getsentry.com', target: '_blank' } https://getsentry.com

    .form-group
      = f.label :sentry_dsn, 'Sentry DSN', class: 'control-label col-sm-2'
      .col-sm-10
        = f.text_field :sentry_dsn, class: 'form-control'

  %fieldset
    %legend 版本仓库检查
    .form-group
      .col-sm-offset-2.col-sm-10
        .checkbox
          = f.label :repository_checks_enabled do
            = f.check_box :repository_checks_enabled
            开启版本仓库检查
          .help-block
            GitLab 将定期给所有项目和维基版本仓库运行
            %a{ href: 'https://www.kernel.org/pub/software/scm/git/docs/git-fsck.html', target: 'blank' } 'git fsck'
            命令来寻找无记载磁盘损坏问题。
    .form-group
      .col-sm-offset-2.col-sm-10
        = link_to '清除所有版本仓库检查', clear_repository_check_states_admin_application_settings_path, data: { confirm: '将清除数据库内所有项目的版本仓库检查状态。此操作无法被撤销。确定要继续么？' }, method: :put, class: "btn btn-sm btn-remove"
        .help-block
          如果在版本仓库检查中得到很多假警报，你可以选择清除数据库中的所有版本仓库检查信息。


  .form-actions
    = f.submit '保存', class: 'btn btn-save'
